package org.dbpt.performance;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String testId = "tests";
		if(args.length > 0) {
			testId = args[0];
		}
		BeanFactory beanFactory = getApplicationConext();
		DBPTItem tests = (DBPTItem) beanFactory.getBean(testId);
		MeasureHolder measureHolder = new MeasureHolder();
		measureHolder.setRootItem(tests);
		tests.prepare();
		tests.doIteration();
		tests.cleanup();
		System.out.println(measureHolder);
	}
	
	private static BeanFactory getApplicationConext() {
		ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
		        new String[] {"application-context2.xml"/*, "applicationContext-part2.xml"*/});
		// of course, an ApplicationContext is just a BeanFactory
		BeanFactory factory = (BeanFactory) appContext;
		return factory;
	}

}
